package gererg;

/**
 * @author leon(liangzou0318@gmail.com)
 * @date 2012-4-25
 * @filaname HanNuo.java
 */
public class HanNuo {

	/**
	 * @param args
	 */
	public void hannuo(int n,char source,char dest,char zhongjian){  //表示先将从源点到终点需要辅助节点
		if(n==1){
			move(source,dest);
		}
		else{
			hannuo(n-1,source,zhongjian,dest);              //表示先将n-1搬到中间节点，再从源点搬到终点
			move(source,dest);
			hannuo(n-1,zhongjian,dest,source);				//再将之前搬到中间节点全都搬到初始节点。
		}
		
	}
	public void move(char source,char dest){
		System.out.println("move "+source+"  to  "+ dest+" ");
	}
	public static void main(String[] args) {
		HanNuo hannuotemp=new HanNuo();
		hannuotemp.hannuo(10, 'A', 'B', 'C');
         
	}

}
